****************************************************************    
*  This file creates the generic macro data for our analysis
*  
****************************************************************

import excel using "${datapath}/MainMacroData.xlsx", sheet("QuarterlyData") firstrow clear
gen Date = yq(Year, Quarter)
format Date %tq
tsset Date, quarterly

gen lnRealGDP = 100*log(RealGDP)    
label var lnRealGDP "real GDP"

gen lnCPISA = 100*log(CPI_SA)
label var lnCPISA "price level"

gen dlnCPISAqoq = lnCPISA - l.lnCPISA
label var dlnCPISAqoq "qoqInfl"

gen RealTaxRev = (TaxRev_ANBV_SA/GDPdeflator)*100
gen lnRealTaxRev = 100*log(RealTaxRev)
label var lnRealTaxRev "taxreceipt"

gen RealExp = (GovExp_ETD/GDPdeflator)*100
gen lnRealExp = 100*log(RealExp)
label var lnRealExp "GovSpend"

gen RealExpCurrent = (GovExpCurrent_ETD/GDPdeflator)*100
gen lnRealExpCurrent = 100*log(RealExpCurrent)
label var lnRealExpCurrent "govCETD"

gen TaxRatio = 100*TaxRev_ANBV_SA/NominalGDP
label var TaxRatio "TaxRatio"

gen ATR = d.TaxRatio
label var ATR "ATR"

gen RealRate = l.BankRate/4 - dlnCPISAqoq 
label var RealRate "eaRealRate"

gen Unemp = Unemployment
label var Unemp "Unemp"

gen SumUnemp = sum(Unemployment)
label var SumUnemp "SumUnemp"

gen RealDef = (Deficit_SA/GDPdeflator)*100  
label var RealDef  "RealDef"

gen DefToGDP    = d.RealDef/l.RealGDP 
label var DefToGDP "DefToGDP"


save ${datapath}/MacroData, replace
